//
//  RedRainView.swift
//  LeGou
//
//  Created by lxm on 2022/10/9.
//

import UIKit
import Lottie

class RedRainView: XMBaseView {

    //MARK: --------------------属性--------------------
    
    //MARK: --------------------UI控件--------------------
    
    @IBOutlet weak var redContent: UIView!
    
    //MARK: --------------------生命周期--------------------
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
        bindAction()
        addConstraints()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        setUI()
        bindAction()
        addConstraints()
    }

    //MARK: --------------------UI--------------------
    func setUI() {
        let starAnimationView = AnimationView(name: "red_lot")
        starAnimationView.play(toProgress: 1, loopMode: .loop)
        starAnimationView.backgroundBehavior = .pauseAndRestore
        redContent.addSubview(starAnimationView)
        starAnimationView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.width.equalTo(rpx(440))
            make.height.equalTo(rpx(329))
        }
    }
    
    func addConstraints() {
        
    }
    
    //MARK: --------------------methods--------------------
    func bindAction() {
        
    }
    
    @IBAction func onClose(_ sender: Any) {
        removeFromSuperview()
    }
    
    
    @IBAction func onRob(_ sender: Any) {
        removeFromSuperview()
        RedBagService.shared.goRedBagVC()
    }
    //MARK: --------------------delegate--------------------

}
